import React, { Component } from 'react'
import Tabcont from './Tabcont'
import Tabtitle from './Tabtitle'
import axios from '../utils/axios'

export class Main extends Component {
    constructor(props) {
      super(props)
    
      this.state = {
         list:[],
         i:0
      }
    }
    componentDidMount(){
        axios.get('/list').then(res=>{
            this.setState({
                list:res.data
            })
        })
    }
    changei(index){
        this.setState({
            i:index
        })
    }
  render() {
      const {list,i}=this.state
    return (
      <div>
          <Tabtitle list={list}></Tabtitle>
          <Tabcont cont={list[i]?list[i].cont:''}></Tabcont>
      </div>
    )
  }
}

export default Main